<template>
  <div class="profile-wrapper">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="用户账号">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="专业班级">
        <el-input v-model="form.class"></el-input>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-input v-model="form.createTime" :disabled="disabled"></el-input>
      </el-form-item>
      <el-form-item label="更新时间">
        <el-input v-model="form.updateTime" :disabled="disabled"></el-input>
      </el-form-item>
      <el-form-item label="兴趣爱好">
        <el-checkbox-group v-model="form.hobby" @change="handleCheckedCitiesChange">
          <el-checkbox v-for="hobby1 in hobbys" :label="hobby1" :key="hobby1">{{hobby1}}</el-checkbox>
        </el-checkbox-group>
        <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
      </el-form-item>
      <el-form-item label="用户性别">
        <el-radio-group v-model="form.sex">
          <el-radio label="男"></el-radio>
          <el-radio label="女"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="form.email" ></el-input>
      </el-form-item>
      <el-form-item label="手机">
        <el-input v-model="form.phone" ></el-input>
      </el-form-item>
      <el-form-item label="账户标识">
        <el-input v-model="form.validFlag" ></el-input>
      </el-form-item>
      <el-form-item>
        <el-form-item label="用户角色">
          <el-radio-group v-model="form.permission">
            <el-radio label="学生" :value="permissionCode"></el-radio>
            <el-radio label="教师" :value="permissionCode"></el-radio>
            <el-radio label="管理员" :value="permissionCode"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-button type="primary" @click="onSubmit">修改</el-button>
        <el-button>修改密码</el-button>
      </el-form-item>

    </el-form>
  </div>
</template>
<script>
  import { mapGetters } from 'vuex'
  const hobbyOptions = ['java编程', '打篮球', '阅读', '电影'];
  export default {
    data() {
      return {
        form: {
          name: '',
          class: '',
          createTime: '',
          updateTime: '',
          disabled: true,
          hobby: [],
          isIndeterminate:'true',
          checkAll:'false',
          sex: '',
          email:'',
          phone: '',
          validFlag:'',
          permission:'',
          permissionCode:''

        }
      }
    },
    computed: {
      ...mapGetters([
        'name',
        'avatar'
      ])
    },
    methods: {
      handleCheckAllChange(val) {
        this.hobby = val ? hobbyOptions : [];
        this.isIndeterminate = false;
      },
      handleCheckedCitiesChange(value) {
        let checkedCount = value.length;
        this.checkAll = checkedCount === this.cities.length;
        this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
      },
      onSubmit() {
        console.log('submit!');
      }
    }
  }
</script>
